document.addEventListener('DOMContentLoaded', function() {
    // CSS淡入淡出轮播控制
    const fadeSlides = document.querySelectorAll('.css-fade-slide');
    let currentFadeIndex = 0;
    
    function showNextFadeSlide() {
        fadeSlides[currentFadeIndex].classList.remove('active');
        currentFadeIndex = (currentFadeIndex + 1) % fadeSlides.length;
        fadeSlides[currentFadeIndex].classList.add('active');
    }
    setInterval(showNextFadeSlide, 3000);
    
    // JavaScript滑动轮播控制
    const slideContainer = document.querySelector('.js-slide-container');
    const slides = document.querySelectorAll('.js-slide');
    const prevBtn = document.querySelector('.js-prev');
    const nextBtn = document.querySelector('.js-next');
    let currentSlideIndex = 0;
    
    function goToSlide(index) {
        if (index < 0) index = slides.length - 1;
        else if (index >= slides.length) index = 0;
        
        currentSlideIndex = index;
        slideContainer.style.transform = `translateX(-${currentSlideIndex * 100}%)`;
    }
    
    nextBtn.addEventListener('click', () => goToSlide(currentSlideIndex + 1));
    prevBtn.addEventListener('click', () => goToSlide(currentSlideIndex - 1));
    setInterval(() => goToSlide(currentSlideIndex + 1), 3000);
});
